﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using V5_DBUtility;
using V5_EShop._Class.Model;

namespace V5_DAL.SqlServer
{
    public class DALGZProduct
    {

        #region  BaseMethod
        /// <summary>
        /// 得到最大ID
        /// </summary>
        public int GetMaxId()
        {
            return DbHelperSQL.GetMaxID("ID", "Bc_Product");
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(Guid ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from Bc_Product");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.UniqueIdentifier,16)
                                        };
            parameters[0].Value = ID;

            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(ModelGZProduct model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into Bc_Product(");
            strSql.Append("ID,ProductTypeID,SerialNo,BarCode,PackageBarCode,ProductName,ProductShortCutName,ProductShortName,UnitID,PackageUnitID,PackageSpec,ManufactureName,MemberPrice,SalePrice1,SalePrice2,SalePrice3,SalePrice4,SalePiecePrice1,SalePiecePrice2,SalePIecePrice3,SalePiecePrice4,MemberDiscont,MaxSalePrice,MinSalePrice,MinSalePiecePrice,MaxSalePiecePrice,IntegralSign,IntegralRate,NoStockCanSales,PriceArithmeticID,MaxInPrice,MaxInPiecePrice,MinInPrice,MinInPiecePrice,StockInPrice,StockInPiecePrice,MaxStockNum,MinStockNum,AverageInPrice,TotalNum,TotalMoney,KeepQulityDate,CreateDate,SpecMode,UserfulLife,ProducingArea,Disable,IsEcalled,PromotionsPrice,PromotionsSDate,PromotionsEDate,ProviderID,LastInDate,LastInPrice,SellerRate,UserRate,RecommendedRate,GiftsBarCode,GiftsIntegral,IsGifts,BrandID,UseDay,IsShow,Remark,Remark1,Remark2,Remark3,Remark4,Remark5,Remark6,Image,ProductDetails,PicturePath,DirectMarketing,Specialofferings,oid)");
            strSql.Append(" values (");
            strSql.Append("@ID,@ProductTypeID,@SerialNo,@BarCode,@PackageBarCode,@ProductName,@ProductShortCutName,@ProductShortName,@UnitID,@PackageUnitID,@PackageSpec,@ManufactureName,@MemberPrice,@SalePrice1,@SalePrice2,@SalePrice3,@SalePrice4,@SalePiecePrice1,@SalePiecePrice2,@SalePIecePrice3,@SalePiecePrice4,@MemberDiscont,@MaxSalePrice,@MinSalePrice,@MinSalePiecePrice,@MaxSalePiecePrice,@IntegralSign,@IntegralRate,@NoStockCanSales,@PriceArithmeticID,@MaxInPrice,@MaxInPiecePrice,@MinInPrice,@MinInPiecePrice,@StockInPrice,@StockInPiecePrice,@MaxStockNum,@MinStockNum,@AverageInPrice,@TotalNum,@TotalMoney,@KeepQulityDate,@CreateDate,@SpecMode,@UserfulLife,@ProducingArea,@Disable,@IsEcalled,@PromotionsPrice,@PromotionsSDate,@PromotionsEDate,@ProviderID,@LastInDate,@LastInPrice,@SellerRate,@UserRate,@RecommendedRate,@GiftsBarCode,@GiftsIntegral,@IsGifts,@BrandID,@UseDay,@IsShow,@Remark,@Remark1,@Remark2,@Remark3,@Remark4,@Remark5,@Remark6,@Image,@ProductDetails,@PicturePath,@DirectMarketing,@Specialofferings,@Oid)");
            SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@ProductTypeID", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@SerialNo", SqlDbType.VarChar,100),
					new SqlParameter("@BarCode", SqlDbType.VarChar,100),
					new SqlParameter("@PackageBarCode", SqlDbType.VarChar,100),
					new SqlParameter("@ProductName", SqlDbType.VarChar,200),
					new SqlParameter("@ProductShortCutName", SqlDbType.VarChar,200),
					new SqlParameter("@ProductShortName", SqlDbType.VarChar,200),
					new SqlParameter("@UnitID", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@PackageUnitID", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@PackageSpec", SqlDbType.Decimal,9),
					new SqlParameter("@ManufactureName", SqlDbType.VarChar,200),
					new SqlParameter("@MemberPrice", SqlDbType.Decimal,9),
					new SqlParameter("@SalePrice1", SqlDbType.Decimal,9),
					new SqlParameter("@SalePrice2", SqlDbType.Decimal,9),
					new SqlParameter("@SalePrice3", SqlDbType.Decimal,9),
					new SqlParameter("@SalePrice4", SqlDbType.Decimal,9),
					new SqlParameter("@SalePiecePrice1", SqlDbType.Decimal,9),
					new SqlParameter("@SalePiecePrice2", SqlDbType.Decimal,9),
					new SqlParameter("@SalePIecePrice3", SqlDbType.Decimal,9),
					new SqlParameter("@SalePiecePrice4", SqlDbType.Decimal,9),
					new SqlParameter("@MemberDiscont", SqlDbType.Decimal,9),
					new SqlParameter("@MaxSalePrice", SqlDbType.Decimal,9),
					new SqlParameter("@MinSalePrice", SqlDbType.Decimal,9),
					new SqlParameter("@MinSalePiecePrice", SqlDbType.Decimal,9),
					new SqlParameter("@MaxSalePiecePrice", SqlDbType.Decimal,9),
					new SqlParameter("@IntegralSign", SqlDbType.Bit,1),
					new SqlParameter("@IntegralRate", SqlDbType.Decimal,9),
					new SqlParameter("@NoStockCanSales", SqlDbType.Bit,1),
					new SqlParameter("@PriceArithmeticID", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@MaxInPrice", SqlDbType.Decimal,9),
					new SqlParameter("@MaxInPiecePrice", SqlDbType.Decimal,9),
					new SqlParameter("@MinInPrice", SqlDbType.Decimal,9),
					new SqlParameter("@MinInPiecePrice", SqlDbType.Decimal,9),
					new SqlParameter("@StockInPrice", SqlDbType.Decimal,9),
					new SqlParameter("@StockInPiecePrice", SqlDbType.Decimal,9),
					new SqlParameter("@MaxStockNum", SqlDbType.Decimal,9),
					new SqlParameter("@MinStockNum", SqlDbType.Decimal,9),
					new SqlParameter("@AverageInPrice", SqlDbType.Decimal,9),
					new SqlParameter("@TotalNum", SqlDbType.Decimal,9),
					new SqlParameter("@TotalMoney", SqlDbType.Decimal,9),
					new SqlParameter("@KeepQulityDate", SqlDbType.DateTime),
					new SqlParameter("@CreateDate", SqlDbType.DateTime),
					new SqlParameter("@SpecMode", SqlDbType.VarChar,200),
					new SqlParameter("@UserfulLife", SqlDbType.Int,4),
					new SqlParameter("@ProducingArea", SqlDbType.VarChar,200),
					new SqlParameter("@Disable", SqlDbType.Bit,1),
					new SqlParameter("@IsEcalled", SqlDbType.Bit,1),
					new SqlParameter("@PromotionsPrice", SqlDbType.Decimal,9),
					new SqlParameter("@PromotionsSDate", SqlDbType.DateTime),
					new SqlParameter("@PromotionsEDate", SqlDbType.DateTime),
					new SqlParameter("@ProviderID", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@LastInDate", SqlDbType.DateTime),
					new SqlParameter("@LastInPrice", SqlDbType.Decimal,9),
					new SqlParameter("@SellerRate", SqlDbType.Decimal,9),
					new SqlParameter("@UserRate", SqlDbType.Decimal,9),
					new SqlParameter("@RecommendedRate", SqlDbType.Decimal,9),
					new SqlParameter("@GiftsBarCode", SqlDbType.VarChar,200),
					new SqlParameter("@GiftsIntegral", SqlDbType.Decimal,9),
					new SqlParameter("@IsGifts", SqlDbType.Bit,1),
					new SqlParameter("@BrandID", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@UseDay", SqlDbType.Int,4),
					new SqlParameter("@IsShow", SqlDbType.Bit,1),
					new SqlParameter("@Remark", SqlDbType.VarChar,4000),
					new SqlParameter("@Remark1", SqlDbType.VarChar,4000),
					new SqlParameter("@Remark2", SqlDbType.VarChar,4000),
					new SqlParameter("@Remark3", SqlDbType.VarChar,4000),
					new SqlParameter("@Remark4", SqlDbType.VarChar,4000),
					new SqlParameter("@Remark5", SqlDbType.VarChar,4000),
					new SqlParameter("@Remark6", SqlDbType.VarChar,4000),
					new SqlParameter("@Image", SqlDbType.Image),
                    new SqlParameter("@ProductDetails", SqlDbType.NText),     
                    new SqlParameter("@PicturePath", SqlDbType.VarChar,100),       
                    new SqlParameter("@DirectMarketing", SqlDbType.Bit,1),
                    new SqlParameter("@Specialofferings", SqlDbType.Bit,1),
                    new SqlParameter("@Oid", SqlDbType.Int,4),
                                        };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.ProductTypeID;
            parameters[2].Value = model.SerialNo;
            parameters[3].Value = model.BarCode;
            parameters[4].Value = model.PackageBarCode;
            parameters[5].Value = model.ProductName;
            parameters[6].Value = model.ProductShortCutName;
            parameters[7].Value = model.ProductShortName;
            parameters[8].Value = model.UnitID;
            parameters[9].Value = model.PackageUnitID;
            parameters[10].Value = model.PackageSpec;
            parameters[11].Value = model.ManufactureName;
            parameters[12].Value = model.MemberPrice;
            parameters[13].Value = model.SalePrice1;
            parameters[14].Value = model.SalePrice2;
            parameters[15].Value = model.SalePrice3;
            parameters[16].Value = model.SalePrice4;
            parameters[17].Value = model.SalePiecePrice1;
            parameters[18].Value = model.SalePiecePrice2;
            parameters[19].Value = model.SalePIecePrice3;
            parameters[20].Value = model.SalePiecePrice4;
            parameters[21].Value = model.MemberDiscont;
            parameters[22].Value = model.MaxSalePrice;
            parameters[23].Value = model.MinSalePrice;
            parameters[24].Value = model.MinSalePiecePrice;
            parameters[25].Value = model.MaxSalePiecePrice;
            parameters[26].Value = model.IntegralSign;
            parameters[27].Value = model.IntegralRate;
            parameters[28].Value = model.NoStockCanSales;
            parameters[29].Value = model.PriceArithmeticID;
            parameters[30].Value = model.MaxInPrice;
            parameters[31].Value = model.MaxInPiecePrice;
            parameters[32].Value = model.MinInPrice;
            parameters[33].Value = model.MinInPiecePrice;
            parameters[34].Value = model.StockInPrice;
            parameters[35].Value = model.StockInPiecePrice;
            parameters[36].Value = model.MaxStockNum;
            parameters[37].Value = model.MinStockNum;
            parameters[38].Value = model.AverageInPrice;
            parameters[39].Value = model.TotalNum;
            parameters[40].Value = model.TotalMoney;
            parameters[41].Value = model.KeepQulityDate;
            parameters[42].Value = model.CreateDate;
            parameters[43].Value = model.SpecMode;
            parameters[44].Value = model.UserfulLife;
            parameters[45].Value = model.ProducingArea;
            parameters[46].Value = model.Disable;
            parameters[47].Value = model.IsEcalled;
            parameters[48].Value = model.PromotionsPrice;
            parameters[49].Value = model.PromotionsSDate;
            parameters[50].Value = model.PromotionsEDate;
            parameters[51].Value = model.ProviderID;
            parameters[52].Value = model.LastInDate;
            parameters[53].Value = model.LastInPrice;
            parameters[54].Value = model.SellerRate;
            parameters[55].Value = model.UserRate;
            parameters[56].Value = model.RecommendedRate;
            parameters[57].Value = model.GiftsBarCode;
            parameters[58].Value = model.GiftsIntegral;
            parameters[59].Value = model.IsGifts;
            parameters[60].Value = model.BrandID;
            parameters[61].Value = model.UseDay;
            parameters[62].Value = model.IsShow;
            parameters[63].Value = model.Remark;
            parameters[64].Value = model.Remark1;
            parameters[65].Value = model.Remark2;
            parameters[66].Value = model.Remark3;
            parameters[67].Value = model.Remark4;
            parameters[68].Value = model.Remark5;
            parameters[69].Value = model.Remark6;
            parameters[70].Value = model.Image;
            parameters[71].Value = model.ProductDetails;
            parameters[72].Value = model.PicturePath;
            parameters[73].Value = model.DirectMarketing;
            parameters[74].Value = model.Specialofferings;
            parameters[75].Value = model.Oid;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ModelGZProduct model)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("update Bc_Product set ");
            strSql.Append("BarCode=@BarCode,");
            strSql.Append("PackageBarCode=@PackageBarCode,");
            strSql.Append("ProductName=@ProductName,");
            strSql.Append("ProductShortCutName=@ProductShortCutName,");
            strSql.Append("ProductShortName=@ProductShortName,");
            strSql.Append("UnitID=@UnitID,");
            strSql.Append("PackageUnitID=@PackageUnitID,");
            strSql.Append("PackageSpec=@PackageSpec,");
            strSql.Append("ManufactureName=@ManufactureName,");
            strSql.Append("MemberPrice=@MemberPrice,");
            strSql.Append("SalePrice1=@SalePrice1,");
            strSql.Append("SalePrice2=@SalePrice2,");
            strSql.Append("SalePrice3=@SalePrice3,");
            strSql.Append("SalePrice4=@SalePrice4,");
            strSql.Append("SalePiecePrice1=@SalePiecePrice1,");
            strSql.Append("SalePiecePrice2=@SalePiecePrice2,");
            strSql.Append("SalePIecePrice3=@SalePIecePrice3,");
            strSql.Append("SalePiecePrice4=@SalePiecePrice4,");
            strSql.Append("MemberDiscont=@MemberDiscont,");
            strSql.Append("MaxSalePrice=@MaxSalePrice,");
            strSql.Append("MinSalePrice=@MinSalePrice,");
            strSql.Append("MinSalePiecePrice=@MinSalePiecePrice,");
            strSql.Append("MaxSalePiecePrice=@MaxSalePiecePrice,");
            strSql.Append("IntegralSign=@IntegralSign,");
            strSql.Append("IntegralRate=@IntegralRate,");
            strSql.Append("NoStockCanSales=@NoStockCanSales,");
            strSql.Append("PriceArithmeticID=@PriceArithmeticID,");
            strSql.Append("MaxInPrice=@MaxInPrice,");
            strSql.Append("MaxInPiecePrice=@MaxInPiecePrice,");
            strSql.Append("MinInPrice=@MinInPrice,");
            strSql.Append("MinInPiecePrice=@MinInPiecePrice,");
            strSql.Append("StockInPrice=@StockInPrice,");
            strSql.Append("StockInPiecePrice=@StockInPiecePrice,");
            strSql.Append("MaxStockNum=@MaxStockNum,");
            strSql.Append("MinStockNum=@MinStockNum,");
            strSql.Append("AverageInPrice=@AverageInPrice,");
            strSql.Append("TotalNum=@TotalNum,");
            strSql.Append("TotalMoney=@TotalMoney,");
            strSql.Append("KeepQulityDate=@KeepQulityDate,");
            strSql.Append("CreateDate=@CreateDate,");
            strSql.Append("SpecMode=@SpecMode,");
            strSql.Append("UserfulLife=@UserfulLife,");
            strSql.Append("ProducingArea=@ProducingArea,");
            strSql.Append("Disable=@Disable,");
            strSql.Append("IsEcalled=@IsEcalled,");
            strSql.Append("PromotionsPrice=@PromotionsPrice,");
            strSql.Append("PromotionsSDate=@PromotionsSDate,");
            strSql.Append("PromotionsEDate=@PromotionsEDate,");
            strSql.Append("ProviderID=@ProviderID,");
            strSql.Append("LastInDate=@LastInDate,");
            strSql.Append("LastInPrice=@LastInPrice,");
            strSql.Append("SellerRate=@SellerRate,");
            strSql.Append("UserRate=@UserRate,");
            strSql.Append("RecommendedRate=@RecommendedRate,");
            strSql.Append("GiftsBarCode=@GiftsBarCode,");
            strSql.Append("GiftsIntegral=@GiftsIntegral,");
            strSql.Append("IsGifts=@IsGifts,");
            strSql.Append("BrandID=@BrandID,");
            strSql.Append("UseDay=@UseDay,");
            strSql.Append("IsShow=@IsShow,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("Remark1=@Remark1,");
            strSql.Append("Remark2=@Remark2,");
            strSql.Append("Remark3=@Remark3,");
            strSql.Append("Remark4=@Remark4,");
            strSql.Append("Remark5=@Remark5,");
            strSql.Append("Remark6=@Remark6,");
            strSql.Append("Image=@Image,");
            strSql.Append("ProductDetails=@ProductDetails,");
            strSql.Append("PicturePath=@PicturePath,");
            strSql.Append("DirectMarketing=@DirectMarketing,");
            strSql.Append("Specialofferings=@Specialofferings,");
            strSql.Append("Oid=@Oid");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters = {
					new SqlParameter("@BarCode", SqlDbType.VarChar,100),
					new SqlParameter("@PackageBarCode", SqlDbType.VarChar,100),
					new SqlParameter("@ProductName", SqlDbType.VarChar,200),
					new SqlParameter("@ProductShortCutName", SqlDbType.VarChar,200),
					new SqlParameter("@ProductShortName", SqlDbType.VarChar,200),
					new SqlParameter("@UnitID", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@PackageUnitID", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@PackageSpec", SqlDbType.Decimal,9),
					new SqlParameter("@ManufactureName", SqlDbType.VarChar,200),
					new SqlParameter("@MemberPrice", SqlDbType.Decimal,9),
					new SqlParameter("@SalePrice1", SqlDbType.Decimal,9),
					new SqlParameter("@SalePrice2", SqlDbType.Decimal,9),
					new SqlParameter("@SalePrice3", SqlDbType.Decimal,9),
					new SqlParameter("@SalePrice4", SqlDbType.Decimal,9),
					new SqlParameter("@SalePiecePrice1", SqlDbType.Decimal,9),
					new SqlParameter("@SalePiecePrice2", SqlDbType.Decimal,9),
					new SqlParameter("@SalePIecePrice3", SqlDbType.Decimal,9),
					new SqlParameter("@SalePiecePrice4", SqlDbType.Decimal,9),
					new SqlParameter("@MemberDiscont", SqlDbType.Decimal,9),
					new SqlParameter("@MaxSalePrice", SqlDbType.Decimal,9),
					new SqlParameter("@MinSalePrice", SqlDbType.Decimal,9),
					new SqlParameter("@MinSalePiecePrice", SqlDbType.Decimal,9),
					new SqlParameter("@MaxSalePiecePrice", SqlDbType.Decimal,9),
					new SqlParameter("@IntegralSign", SqlDbType.Bit,1),
					new SqlParameter("@IntegralRate", SqlDbType.Decimal,9),
					new SqlParameter("@NoStockCanSales", SqlDbType.Bit,1),
					new SqlParameter("@PriceArithmeticID", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@MaxInPrice", SqlDbType.Decimal,9),
					new SqlParameter("@MaxInPiecePrice", SqlDbType.Decimal,9),
					new SqlParameter("@MinInPrice", SqlDbType.Decimal,9),
					new SqlParameter("@MinInPiecePrice", SqlDbType.Decimal,9),
					new SqlParameter("@StockInPrice", SqlDbType.Decimal,9),
					new SqlParameter("@StockInPiecePrice", SqlDbType.Decimal,9),
					new SqlParameter("@MaxStockNum", SqlDbType.Decimal,9),
					new SqlParameter("@MinStockNum", SqlDbType.Decimal,9),
					new SqlParameter("@AverageInPrice", SqlDbType.Decimal,9),
					new SqlParameter("@TotalNum", SqlDbType.Decimal,9),
					new SqlParameter("@TotalMoney", SqlDbType.Decimal,9),
					new SqlParameter("@KeepQulityDate", SqlDbType.DateTime),
					new SqlParameter("@CreateDate", SqlDbType.DateTime),
					new SqlParameter("@SpecMode", SqlDbType.VarChar,200),
					new SqlParameter("@UserfulLife", SqlDbType.Int,4),
					new SqlParameter("@ProducingArea", SqlDbType.VarChar,200),
					new SqlParameter("@Disable", SqlDbType.Bit,1),
					new SqlParameter("@IsEcalled", SqlDbType.Bit,1),
					new SqlParameter("@PromotionsPrice", SqlDbType.Decimal,9),
					new SqlParameter("@PromotionsSDate", SqlDbType.DateTime),
					new SqlParameter("@PromotionsEDate", SqlDbType.DateTime),
					new SqlParameter("@ProviderID", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@LastInDate", SqlDbType.DateTime),
					new SqlParameter("@LastInPrice", SqlDbType.Decimal,9),
					new SqlParameter("@SellerRate", SqlDbType.Decimal,9),
					new SqlParameter("@UserRate", SqlDbType.Decimal,9),
					new SqlParameter("@RecommendedRate", SqlDbType.Decimal,9),
					new SqlParameter("@GiftsBarCode", SqlDbType.VarChar,200),
					new SqlParameter("@GiftsIntegral", SqlDbType.Decimal,9),
					new SqlParameter("@IsGifts", SqlDbType.Bit,1),
					new SqlParameter("@BrandID", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@UseDay", SqlDbType.Int,4),
					new SqlParameter("@IsShow", SqlDbType.Bit,1),
					new SqlParameter("@Remark", SqlDbType.VarChar,4000),
					new SqlParameter("@Remark1", SqlDbType.VarChar,4000),
					new SqlParameter("@Remark2", SqlDbType.VarChar,4000),
					new SqlParameter("@Remark3", SqlDbType.VarChar,4000),
					new SqlParameter("@Remark4", SqlDbType.VarChar,4000),
					new SqlParameter("@Remark5", SqlDbType.VarChar,4000),
					new SqlParameter("@Remark6", SqlDbType.VarChar,4000),
					new SqlParameter("@Image", SqlDbType.Image),
					new SqlParameter("@ID", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@ProductTypeID", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@SerialNo", SqlDbType.VarChar,100),
                    new SqlParameter("@ProductDetails", SqlDbType.NText),      
                    new SqlParameter("@PicturePath", SqlDbType.VarChar,100),   
                    new SqlParameter("@DirectMarketing", SqlDbType.Bit,1),
                    new SqlParameter("@Specialofferings", SqlDbType.Bit,1),
                    new SqlParameter("@Oid", SqlDbType.Int,4),
                                        };
            parameters[0].Value = model.BarCode;
            parameters[1].Value = model.PackageBarCode;
            parameters[2].Value = model.ProductName;
            parameters[3].Value = model.ProductShortCutName;
            parameters[4].Value = model.ProductShortName;
            parameters[5].Value = model.UnitID;
            parameters[6].Value = model.PackageUnitID;
            parameters[7].Value = model.PackageSpec;
            parameters[8].Value = model.ManufactureName;
            parameters[9].Value = model.MemberPrice;
            parameters[10].Value = model.SalePrice1;
            parameters[11].Value = model.SalePrice2;
            parameters[12].Value = model.SalePrice3;
            parameters[13].Value = model.SalePrice4;
            parameters[14].Value = model.SalePiecePrice1;
            parameters[15].Value = model.SalePiecePrice2;
            parameters[16].Value = model.SalePIecePrice3;
            parameters[17].Value = model.SalePiecePrice4;
            parameters[18].Value = model.MemberDiscont;
            parameters[19].Value = model.MaxSalePrice;
            parameters[20].Value = model.MinSalePrice;
            parameters[21].Value = model.MinSalePiecePrice;
            parameters[22].Value = model.MaxSalePiecePrice;
            parameters[23].Value = model.IntegralSign;
            parameters[24].Value = model.IntegralRate;
            parameters[25].Value = model.NoStockCanSales;
            parameters[26].Value = model.PriceArithmeticID;
            parameters[27].Value = model.MaxInPrice;
            parameters[28].Value = model.MaxInPiecePrice;
            parameters[29].Value = model.MinInPrice;
            parameters[30].Value = model.MinInPiecePrice;
            parameters[31].Value = model.StockInPrice;
            parameters[32].Value = model.StockInPiecePrice;
            parameters[33].Value = model.MaxStockNum;
            parameters[34].Value = model.MinStockNum;
            parameters[35].Value = model.AverageInPrice;
            parameters[36].Value = model.TotalNum;
            parameters[37].Value = model.TotalMoney;
            parameters[38].Value = model.KeepQulityDate;
            parameters[39].Value = model.CreateDate;
            parameters[40].Value = model.SpecMode;
            parameters[41].Value = model.UserfulLife;
            parameters[42].Value = model.ProducingArea;
            parameters[43].Value = model.Disable;
            parameters[44].Value = model.IsEcalled;
            parameters[45].Value = model.PromotionsPrice;
            parameters[46].Value = model.PromotionsSDate;
            parameters[47].Value = model.PromotionsEDate;
            parameters[48].Value = model.ProviderID;
            parameters[49].Value = model.LastInDate;
            parameters[50].Value = model.LastInPrice;
            parameters[51].Value = model.SellerRate;
            parameters[52].Value = model.UserRate;
            parameters[53].Value = model.RecommendedRate;
            parameters[54].Value = model.GiftsBarCode;
            parameters[55].Value = model.GiftsIntegral;
            parameters[56].Value = model.IsGifts;
            parameters[57].Value = model.BrandID;
            parameters[58].Value = model.UseDay;
            parameters[59].Value = model.IsShow;
            parameters[60].Value = model.Remark;
            parameters[61].Value = model.Remark1;
            parameters[62].Value = model.Remark2;
            parameters[63].Value = model.Remark3;
            parameters[64].Value = model.Remark4;
            parameters[65].Value = model.Remark5;
            parameters[66].Value = model.Remark6;
            parameters[67].Value = model.Image;
            parameters[68].Value = model.ID;
            parameters[69].Value = model.ProductTypeID;
            parameters[70].Value = model.SerialNo;
            parameters[71].Value = model.ProductDetails;
            parameters[72].Value = model.PicturePath;
            parameters[73].Value = model.DirectMarketing;
            parameters[74].Value = model.Specialofferings;
            parameters[75].Value = model.Oid;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(Guid ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from Bc_Product ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.UniqueIdentifier,16)};
            parameters[0].Value = ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ModelGZProduct GetModel(Guid ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 * from Bc_Product ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.UniqueIdentifier,16)};
            parameters[0].Value = ID;

            ModelGZProduct model = new ModelGZProduct();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = new Guid(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProductTypeID"] != null && ds.Tables[0].Rows[0]["ProductTypeID"].ToString() != "")
                {
                    model.ProductTypeID = new Guid(ds.Tables[0].Rows[0]["ProductTypeID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SerialNo"] != null && ds.Tables[0].Rows[0]["SerialNo"].ToString() != "")
                {
                    model.SerialNo = ds.Tables[0].Rows[0]["SerialNo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["BarCode"] != null && ds.Tables[0].Rows[0]["BarCode"].ToString() != "")
                {
                    model.BarCode = ds.Tables[0].Rows[0]["BarCode"].ToString();
                }
                if (ds.Tables[0].Rows[0]["PackageBarCode"] != null && ds.Tables[0].Rows[0]["PackageBarCode"].ToString() != "")
                {
                    model.PackageBarCode = ds.Tables[0].Rows[0]["PackageBarCode"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductName"] != null && ds.Tables[0].Rows[0]["ProductName"].ToString() != "")
                {
                    model.ProductName = ds.Tables[0].Rows[0]["ProductName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductShortCutName"] != null && ds.Tables[0].Rows[0]["ProductShortCutName"].ToString() != "")
                {
                    model.ProductShortCutName = ds.Tables[0].Rows[0]["ProductShortCutName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ProductShortName"] != null && ds.Tables[0].Rows[0]["ProductShortName"].ToString() != "")
                {
                    model.ProductShortName = ds.Tables[0].Rows[0]["ProductShortName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["UnitID"] != null && ds.Tables[0].Rows[0]["UnitID"].ToString() != "")
                {
                    model.UnitID = new Guid(ds.Tables[0].Rows[0]["UnitID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PackageUnitID"] != null && ds.Tables[0].Rows[0]["PackageUnitID"].ToString() != "")
                {
                    model.PackageUnitID = new Guid(ds.Tables[0].Rows[0]["PackageUnitID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PackageSpec"] != null && ds.Tables[0].Rows[0]["PackageSpec"].ToString() != "")
                {
                    model.PackageSpec = decimal.Parse(ds.Tables[0].Rows[0]["PackageSpec"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ManufactureName"] != null && ds.Tables[0].Rows[0]["ManufactureName"].ToString() != "")
                {
                    model.ManufactureName = ds.Tables[0].Rows[0]["ManufactureName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["MemberPrice"] != null && ds.Tables[0].Rows[0]["MemberPrice"].ToString() != "")
                {
                    model.MemberPrice = decimal.Parse(ds.Tables[0].Rows[0]["MemberPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SalePrice1"] != null && ds.Tables[0].Rows[0]["SalePrice1"].ToString() != "")
                {
                    model.SalePrice1 = decimal.Parse(ds.Tables[0].Rows[0]["SalePrice1"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SalePrice2"] != null && ds.Tables[0].Rows[0]["SalePrice2"].ToString() != "")
                {
                    model.SalePrice2 = decimal.Parse(ds.Tables[0].Rows[0]["SalePrice2"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SalePrice3"] != null && ds.Tables[0].Rows[0]["SalePrice3"].ToString() != "")
                {
                    model.SalePrice3 = decimal.Parse(ds.Tables[0].Rows[0]["SalePrice3"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SalePrice4"] != null && ds.Tables[0].Rows[0]["SalePrice4"].ToString() != "")
                {
                    model.SalePrice4 = decimal.Parse(ds.Tables[0].Rows[0]["SalePrice4"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SalePiecePrice1"] != null && ds.Tables[0].Rows[0]["SalePiecePrice1"].ToString() != "")
                {
                    model.SalePiecePrice1 = decimal.Parse(ds.Tables[0].Rows[0]["SalePiecePrice1"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SalePiecePrice2"] != null && ds.Tables[0].Rows[0]["SalePiecePrice2"].ToString() != "")
                {
                    model.SalePiecePrice2 = decimal.Parse(ds.Tables[0].Rows[0]["SalePiecePrice2"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SalePIecePrice3"] != null && ds.Tables[0].Rows[0]["SalePIecePrice3"].ToString() != "")
                {
                    model.SalePIecePrice3 = decimal.Parse(ds.Tables[0].Rows[0]["SalePIecePrice3"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SalePiecePrice4"] != null && ds.Tables[0].Rows[0]["SalePiecePrice4"].ToString() != "")
                {
                    model.SalePiecePrice4 = decimal.Parse(ds.Tables[0].Rows[0]["SalePiecePrice4"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MemberDiscont"] != null && ds.Tables[0].Rows[0]["MemberDiscont"].ToString() != "")
                {
                    model.MemberDiscont = decimal.Parse(ds.Tables[0].Rows[0]["MemberDiscont"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MaxSalePrice"] != null && ds.Tables[0].Rows[0]["MaxSalePrice"].ToString() != "")
                {
                    model.MaxSalePrice = decimal.Parse(ds.Tables[0].Rows[0]["MaxSalePrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MinSalePrice"] != null && ds.Tables[0].Rows[0]["MinSalePrice"].ToString() != "")
                {
                    model.MinSalePrice = decimal.Parse(ds.Tables[0].Rows[0]["MinSalePrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MinSalePiecePrice"] != null && ds.Tables[0].Rows[0]["MinSalePiecePrice"].ToString() != "")
                {
                    model.MinSalePiecePrice = decimal.Parse(ds.Tables[0].Rows[0]["MinSalePiecePrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MaxSalePiecePrice"] != null && ds.Tables[0].Rows[0]["MaxSalePiecePrice"].ToString() != "")
                {
                    model.MaxSalePiecePrice = decimal.Parse(ds.Tables[0].Rows[0]["MaxSalePiecePrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IntegralSign"] != null && ds.Tables[0].Rows[0]["IntegralSign"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["IntegralSign"].ToString() == "1") || (ds.Tables[0].Rows[0]["IntegralSign"].ToString().ToLower() == "true"))
                    {
                        model.IntegralSign = true;
                    }
                    else
                    {
                        model.IntegralSign = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["IntegralRate"] != null && ds.Tables[0].Rows[0]["IntegralRate"].ToString() != "")
                {
                    model.IntegralRate = decimal.Parse(ds.Tables[0].Rows[0]["IntegralRate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["NoStockCanSales"] != null && ds.Tables[0].Rows[0]["NoStockCanSales"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["NoStockCanSales"].ToString() == "1") || (ds.Tables[0].Rows[0]["NoStockCanSales"].ToString().ToLower() == "true"))
                    {
                        model.NoStockCanSales = true;
                    }
                    else
                    {
                        model.NoStockCanSales = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["PriceArithmeticID"] != null && ds.Tables[0].Rows[0]["PriceArithmeticID"].ToString() != "")
                {
                    model.PriceArithmeticID = new Guid(ds.Tables[0].Rows[0]["PriceArithmeticID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MaxInPrice"] != null && ds.Tables[0].Rows[0]["MaxInPrice"].ToString() != "")
                {
                    model.MaxInPrice = decimal.Parse(ds.Tables[0].Rows[0]["MaxInPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MaxInPiecePrice"] != null && ds.Tables[0].Rows[0]["MaxInPiecePrice"].ToString() != "")
                {
                    model.MaxInPiecePrice = decimal.Parse(ds.Tables[0].Rows[0]["MaxInPiecePrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MinInPrice"] != null && ds.Tables[0].Rows[0]["MinInPrice"].ToString() != "")
                {
                    model.MinInPrice = decimal.Parse(ds.Tables[0].Rows[0]["MinInPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MinInPiecePrice"] != null && ds.Tables[0].Rows[0]["MinInPiecePrice"].ToString() != "")
                {
                    model.MinInPiecePrice = decimal.Parse(ds.Tables[0].Rows[0]["MinInPiecePrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["StockInPrice"] != null && ds.Tables[0].Rows[0]["StockInPrice"].ToString() != "")
                {
                    model.StockInPrice = decimal.Parse(ds.Tables[0].Rows[0]["StockInPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["StockInPiecePrice"] != null && ds.Tables[0].Rows[0]["StockInPiecePrice"].ToString() != "")
                {
                    model.StockInPiecePrice = decimal.Parse(ds.Tables[0].Rows[0]["StockInPiecePrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MaxStockNum"] != null && ds.Tables[0].Rows[0]["MaxStockNum"].ToString() != "")
                {
                    model.MaxStockNum = decimal.Parse(ds.Tables[0].Rows[0]["MaxStockNum"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MinStockNum"] != null && ds.Tables[0].Rows[0]["MinStockNum"].ToString() != "")
                {
                    model.MinStockNum = decimal.Parse(ds.Tables[0].Rows[0]["MinStockNum"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AverageInPrice"] != null && ds.Tables[0].Rows[0]["AverageInPrice"].ToString() != "")
                {
                    model.AverageInPrice = decimal.Parse(ds.Tables[0].Rows[0]["AverageInPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TotalNum"] != null && ds.Tables[0].Rows[0]["TotalNum"].ToString() != "")
                {
                    model.TotalNum = decimal.Parse(ds.Tables[0].Rows[0]["TotalNum"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TotalMoney"] != null && ds.Tables[0].Rows[0]["TotalMoney"].ToString() != "")
                {
                    model.TotalMoney = decimal.Parse(ds.Tables[0].Rows[0]["TotalMoney"].ToString());
                }
                if (ds.Tables[0].Rows[0]["KeepQulityDate"] != null && ds.Tables[0].Rows[0]["KeepQulityDate"].ToString() != "")
                {
                    model.KeepQulityDate = DateTime.Parse(ds.Tables[0].Rows[0]["KeepQulityDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CreateDate"] != null && ds.Tables[0].Rows[0]["CreateDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SpecMode"] != null && ds.Tables[0].Rows[0]["SpecMode"].ToString() != "")
                {
                    model.SpecMode = ds.Tables[0].Rows[0]["SpecMode"].ToString();
                }
                if (ds.Tables[0].Rows[0]["UserfulLife"] != null && ds.Tables[0].Rows[0]["UserfulLife"].ToString() != "")
                {
                    model.UserfulLife = int.Parse(ds.Tables[0].Rows[0]["UserfulLife"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProducingArea"] != null && ds.Tables[0].Rows[0]["ProducingArea"].ToString() != "")
                {
                    model.ProducingArea = ds.Tables[0].Rows[0]["ProducingArea"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Disable"] != null && ds.Tables[0].Rows[0]["Disable"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Disable"].ToString() == "1") || (ds.Tables[0].Rows[0]["Disable"].ToString().ToLower() == "true"))
                    {
                        model.Disable = true;
                    }
                    else
                    {
                        model.Disable = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["IsEcalled"] != null && ds.Tables[0].Rows[0]["IsEcalled"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["IsEcalled"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsEcalled"].ToString().ToLower() == "true"))
                    {
                        model.IsEcalled = true;
                    }
                    else
                    {
                        model.IsEcalled = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["PromotionsPrice"] != null && ds.Tables[0].Rows[0]["PromotionsPrice"].ToString() != "")
                {
                    model.PromotionsPrice = decimal.Parse(ds.Tables[0].Rows[0]["PromotionsPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PromotionsSDate"] != null && ds.Tables[0].Rows[0]["PromotionsSDate"].ToString() != "")
                {
                    model.PromotionsSDate = DateTime.Parse(ds.Tables[0].Rows[0]["PromotionsSDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PromotionsEDate"] != null && ds.Tables[0].Rows[0]["PromotionsEDate"].ToString() != "")
                {
                    model.PromotionsEDate = DateTime.Parse(ds.Tables[0].Rows[0]["PromotionsEDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProviderID"] != null && ds.Tables[0].Rows[0]["ProviderID"].ToString() != "")
                {
                    model.ProviderID = new Guid(ds.Tables[0].Rows[0]["ProviderID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["LastInDate"] != null && ds.Tables[0].Rows[0]["LastInDate"].ToString() != "")
                {
                    model.LastInDate = DateTime.Parse(ds.Tables[0].Rows[0]["LastInDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["LastInPrice"] != null && ds.Tables[0].Rows[0]["LastInPrice"].ToString() != "")
                {
                    model.LastInPrice = decimal.Parse(ds.Tables[0].Rows[0]["LastInPrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SellerRate"] != null && ds.Tables[0].Rows[0]["SellerRate"].ToString() != "")
                {
                    model.SellerRate = decimal.Parse(ds.Tables[0].Rows[0]["SellerRate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UserRate"] != null && ds.Tables[0].Rows[0]["UserRate"].ToString() != "")
                {
                    model.UserRate = decimal.Parse(ds.Tables[0].Rows[0]["UserRate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["RecommendedRate"] != null && ds.Tables[0].Rows[0]["RecommendedRate"].ToString() != "")
                {
                    model.RecommendedRate = decimal.Parse(ds.Tables[0].Rows[0]["RecommendedRate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["GiftsBarCode"] != null && ds.Tables[0].Rows[0]["GiftsBarCode"].ToString() != "")
                {
                    model.GiftsBarCode = ds.Tables[0].Rows[0]["GiftsBarCode"].ToString();
                }
                if (ds.Tables[0].Rows[0]["GiftsIntegral"] != null && ds.Tables[0].Rows[0]["GiftsIntegral"].ToString() != "")
                {
                    model.GiftsIntegral = decimal.Parse(ds.Tables[0].Rows[0]["GiftsIntegral"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsGifts"] != null && ds.Tables[0].Rows[0]["IsGifts"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["IsGifts"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsGifts"].ToString().ToLower() == "true"))
                    {
                        model.IsGifts = true;
                    }
                    else
                    {
                        model.IsGifts = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["BrandID"] != null && ds.Tables[0].Rows[0]["BrandID"].ToString() != "")
                {
                    model.BrandID = new Guid(ds.Tables[0].Rows[0]["BrandID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UseDay"] != null && ds.Tables[0].Rows[0]["UseDay"].ToString() != "")
                {
                    model.UseDay = int.Parse(ds.Tables[0].Rows[0]["UseDay"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsShow"] != null && ds.Tables[0].Rows[0]["IsShow"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["IsShow"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsShow"].ToString().ToLower() == "true"))
                    {
                        model.IsShow = true;
                    }
                    else
                    {
                        model.IsShow = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["Remark"] != null && ds.Tables[0].Rows[0]["Remark"].ToString() != "")
                {
                    model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Remark1"] != null && ds.Tables[0].Rows[0]["Remark1"].ToString() != "")
                {
                    model.Remark1 = ds.Tables[0].Rows[0]["Remark1"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Remark2"] != null && ds.Tables[0].Rows[0]["Remark2"].ToString() != "")
                {
                    model.Remark2 = ds.Tables[0].Rows[0]["Remark2"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Remark3"] != null && ds.Tables[0].Rows[0]["Remark3"].ToString() != "")
                {
                    model.Remark3 = ds.Tables[0].Rows[0]["Remark3"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Remark4"] != null && ds.Tables[0].Rows[0]["Remark4"].ToString() != "")
                {
                    model.Remark4 = ds.Tables[0].Rows[0]["Remark4"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Remark5"] != null && ds.Tables[0].Rows[0]["Remark5"].ToString() != "")
                {
                    model.Remark5 = ds.Tables[0].Rows[0]["Remark5"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Remark6"] != null && ds.Tables[0].Rows[0]["Remark6"].ToString() != "")
                {
                    model.Remark6 = ds.Tables[0].Rows[0]["Remark6"].ToString();
                }

                //if (ds.Tables[0].Rows[0]["Timestamp"] != null && ds.Tables[0].Rows[0]["Timestamp"].ToString() != "") {
                //    model.Timestamp = DateTime.Parse(ds.Tables[0].Rows[0]["Timestamp"].ToString());
                //}
                if (ds.Tables[0].Rows[0]["Image"] != null && ds.Tables[0].Rows[0]["Image"].ToString() != "")
                {
                    model.Image = (byte[])ds.Tables[0].Rows[0]["Image"];
                }
                if (ds.Tables[0].Rows[0]["ProductDetails"] != null && ds.Tables[0].Rows[0]["ProductDetails"].ToString() != "")
                {
                    model.ProductDetails = ds.Tables[0].Rows[0]["ProductDetails"].ToString();
                }
                if (ds.Tables[0].Rows[0]["PicturePath"] != null && ds.Tables[0].Rows[0]["PicturePath"].ToString() != "")
                {
                    model.PicturePath = ds.Tables[0].Rows[0]["PicturePath"].ToString();
                }
                if (ds.Tables[0].Rows[0]["DirectMarketing"] != null && ds.Tables[0].Rows[0]["DirectMarketing"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["DirectMarketing"].ToString() == "1") || (ds.Tables[0].Rows[0]["DirectMarketing"].ToString().ToLower() == "true"))
                    {
                        model.DirectMarketing = true;
                    }
                    else
                    {
                        model.DirectMarketing = false;
                    }
                }

                if (ds.Tables[0].Rows[0]["Specialofferings"] != null && ds.Tables[0].Rows[0]["Specialofferings"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Specialofferings"].ToString() == "1") || (ds.Tables[0].Rows[0]["Specialofferings"].ToString().ToLower() == "true"))
                    {
                        model.Specialofferings = true;
                    }
                    else
                    {
                        model.Specialofferings = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["Oid"] != null && ds.Tables[0].Rows[0]["Oid"].ToString() != "")
                {
                    model.Oid = int.Parse(ds.Tables[0].Rows[0]["Oid"].ToString());
                }

                return model;
            }
            else
            {
                return null;
            }
        }

        public bool DeleteList(string IDlist)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from Bc_Product ");
            strSql.Append(" where ID in (" + IDlist + ")  ");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * ");
            strSql.Append(" FROM Bc_Product ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return this.GetList("*", Top, strWhere, filedOrder);
        }

        public DataSet GetList(int PageSize, int PageIndex, string strWhere, string strOrder, ref int RecordCount)
        {
            return this.GetList("*", PageSize, PageIndex, strWhere, strOrder, ref RecordCount);
        }

        public DataSet GetList(string strFiled, string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select " + strFiled + " ");
            strSql.Append(" FROM Bc_Product ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where 1=1 " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        public DataSet GetList(string strFiled, int Top, string strWhere, string filedOrder)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (Top > 0)
            {
                strSql.Append(" Top " + Top.ToString());
            }
            strSql.Append(" " + strFiled + " ");
            strSql.Append(" FROM Bc_Product ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where 1=1 " + strWhere);
            }
            if (filedOrder.Trim() != "")
            {
                strSql.Append(" order by " + filedOrder);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 获取记录总数
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) FROM Bc_Product ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            object obj = DbHelperSQL.GetSingle(strSql.ToString());
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }

        public DataSet GetList(string strFiled, int PageSize, int PageIndex, string strWhere, string strOrder, ref int RecordCount)
        {
            SqlParameter[] parameters = {
                                        new SqlParameter("@tblName", SqlDbType.VarChar, 255),
                                        new SqlParameter("@fldName", SqlDbType.VarChar, 255),
                                        new SqlParameter("@indexfldName", SqlDbType.VarChar, 255),
                                        new SqlParameter("@StatfldName", SqlDbType.VarChar, 255),
                                        new SqlParameter("@PageSize", SqlDbType.Int,4),
                                        new SqlParameter("@PageIndex", SqlDbType.Int,4),
                                        new SqlParameter("@IsReCount", SqlDbType.Bit,1),
                                        new SqlParameter("@strWhere", SqlDbType.VarChar, 1000),
                                        new SqlParameter("@strOrderby", SqlDbType.VarChar, 1000),
                                        };
            parameters[0].Value = "Bc_Product";
            parameters[1].Value = strFiled;
            parameters[2].Value = "ID";
            parameters[3].Value = "ID";
            parameters[4].Value = PageSize;
            parameters[5].Value = PageIndex;
            parameters[6].Value = 1;
            parameters[7].Value = strWhere;
            parameters[8].Value = strOrder;
            DataSet ds = DbHelperSQL.RunProcedure("UP_GetRecordByPageOrderWhere", parameters, "ds");
            RecordCount = int.Parse("0" + ds.Tables[1].Rows[0][0].ToString());
            return ds;
        }

        #endregion Bc_Product结束




    }
}